package com.finance.service;

import com.finance.util.DataType;
import com.finance.util.SearchDateType;

import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.Map;

public class FinanceService {

    public static void main(String[] args) throws UnsupportedEncodingException {
        //https://gw.open.yuekeyun.com/openapi/param2/1/alibaba.dme.lark/dme.lark.data.finance.getFinancialData/40957?
        //leaseCode=democs&dataType=C01&searchDateType=day&searchDate=2019-01-
        //01&callBackUrl=www&channelCode=LP_TEST&cinemaLinkIds=%5B%2290006%22%2C%22900
        //07%22%5D&_aop_signature=D3CE079A72E2D821A820BCA1C9FC9A38A590AFE6&_aop_timest
        //amp=1607182375130

        //https://gw.open.yuekeyun.com/openapi/param2/1/alibaba.dme.lark/dme.lark.ticket.schedule.getScheduleList/879234
        String host = "gw.open.yuekeyun.com";
        String client_id = "879234";
        String appSecret = "kamKHH38X5d";
        Map<String, String> params = new HashMap<String, String>();
        params.put("client_id", client_id);
        params.put("client_secret", appSecret);
        params.put("leaseCode", "empc");
        params.put("channelCode", "EMPC_OPEN");
        params.put("cinemaLinkIds", "[\"12368\"]");
        params.put("cinemaLinkId", "12368");
        params.put("dataType", DataType.C01.getCode());
        params.put("searchDateType", SearchDateType.DAY.getCode());

        //查询⽇期1.2019-05-09，数据范围为2019-05-09 06:00:00-2019-05-10 05:59:59
        //2.2019-05,数据范围为 2019-05-01 06:00:00-2019-06-01 05:59:59
        params.put("searchDate", "2025-05-09");
        //&_aop_timestamp=1375703483649
        params.put("_aop_timestamp", System.currentTimeMillis() + "");
        //快照⽇期(C22使⽤)
//        params.put("snapshotDate", refreshToken);
        //有效期开始(C22使⽤)
//        params.put("beginDate", refreshToken);
        //有效期结束(C22使⽤)
//        params.put("endDate", refreshToken);
        //开卡/发卡时间类型（C03使⽤）不填或空，默认按发卡时间查询1：发卡时间；2：开卡时间；
//        params.put("type", refreshToken);
        //test call api
        String urlHead = "https://" + host + "/openapi/";
        String urlPath = "param2/1/alibaba.dme.lark/dme.lark.ticket.schedule.getScheduleList/879234";
//        Map<String, String> param = new HashMap<String, String>();
//        param.put("access_token", (String) jsonObject1.get("access_token"));
        String result = ApiCallService.callApiTest(urlHead, urlPath, appSecret, params);
        System.out.println(result);
    }

}
